﻿using JESAI.HttpRequestMonitor.Core.Abstracts;
using JESAI.HttpRequestMonitor.Core.Enums;
using JESAI.HttpRequestMonitor.Core.Exceptions;
using JESAI.HttpRequestMonitor.Core.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace JESAI.HttpRequestMonitor.Core.Creator
{
    public class DefaultModelCreator : IModelCreator
    {
        public virtual IMonitorModel CreateMonitorModel(MonitorType monitorType)
        {
            switch (monitorType)
            {
                case MonitorType.ResponseTimeOut:
                    return new ResponseTimeOutMonitorModel();

                case MonitorType.ResponseError:
                    return new ErrorResponseMonitorModel();

                case MonitorType.ToManyRequestWithAddress:
                    return new RequestTimesMonitorModel();

                case MonitorType.ToManyRequestBySingleRemoteAddress:
                    return new RemoteAddressRequestTimesMonitorModel();

                case MonitorType.UnDefine:
                default:
                    throw new UnSupportMonitorException($"Unknown Type:{monitorType}");
            }
        }

        public virtual IMonitorRuleModel CreateMonitorRuleModel() => new MonitorRuleModel();

        public virtual IRequestDetailModel CreateRequestDetailModel() => new RequestDetailModel();

        public virtual IRequestModel CreateRequestModel() => new RequestModel();
    }
}
